<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<strong><%@ taglib prefix="c"
                   uri="http://java.sun.com/jsp/jstl/core" %></strong>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>拍卖会</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/xAdmin/css/font.css">
    <link rel="stylesheet" href="/xAdmin/css/xadmin.css">
    <link rel="stylesheet" href="/xAdmin/lib/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="/xAdmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/xAdmin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form method="post" class="layui-form">
            <input type="hidden" value="${auc.id}" id="aucid">
            <div class="layui-form-item">
                <label for="auctionname" class="layui-form-label">
                    拍卖会名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="auctionname" name="auctionname" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="${auc.auctionname}">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label for="statetime" class="layui-form-label">
                        开始时间
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="statetime" name="statetime" placeholder="yyyy-MM-dd HH:mm:ss" value="${auc.statetime}">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="endtime" class="layui-form-label">
                    结束时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="endtime" name="endtime" placeholder="yyyy-MM-dd HH:mm:ss" value="${auc.endtime}">
                </div>
            </div>
<%--            <div class="layui-form-item">--%>
<%--                <label for="art" class="layui-form-label">--%>
<%--                    拍卖作品--%>
<%--                </label>--%>
<%--                <div class="layui-input-inline">--%>
<%--                    <input type="hidden" id="artcodes" name="artcodes" value="${auc.artcodes}">--%>
<%--                    <input type="text" id="artnames" name="artnames" required="" lay-verify="required"--%>
<%--                           autocomplete="off" class="layui-input" value="${auc.artcode}" >--%>
<%--                    <button type="button" class="layui-btn" lay-filter="choose" id="choose">--%>
<%--                        艺术品--%>
<%--                    </button>--%>
<%--                </div>--%>
<%--            </div>--%>
            <div class="layui-form-item">
                <label for="auctionname" class="layui-form-label">
                    地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="address" name="address" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="${auc.address}">

                </div>
            </div>
<%--            <div class="layui-form-item">--%>
<%--                <label for="auctionname" class="layui-form-label">--%>
<%--                    拍卖类型--%>
<%--                </label>--%>
<%--                <div class="layui-input-inline">--%>
<%--                    <input type="text" id="type" name="type" required="" lay-verify="required"--%>
<%--                           autocomplete="off" class="layui-input" value="${auc.type}">--%>
<%--                </div>--%>
<%--            </div>--%>
            <div class="layui-form-item">
                <label for="auctionname" class="layui-form-label">
                    保证金
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="securityprice" name="securityprice" required="" lay-verify="required"
                           autocomplete="off" class="layui-input" value="${auc.securityprice}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="posterPicture" class="layui-form-label">
                    <button type="button" class="layui-btn" id="file" name="file">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                </label>
                <div class="layui-input-block">
                    <input type="hidden" id="posterPictureValue" value="${auc.posterPicture}">
                    <img src="${auc.posterPictureShow}" id="posterPicture">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="description" class="layui-form-label">
                    拍卖会描述
                </label>
                <div class="layui-input-block" >
                    <input type="hidden" value="${auc.content}" id="descriptiondesc">
                    <textarea name="content" style="width: 200px" id="content" placeholder="请输入内容" class="layui-textarea" ></textarea>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button type="button" class="layui-btn" lay-filter="add"  onclick="Issubmit()">
                    确定
                </button>
            </div>

        </form>
    </div>
</div>
<script>

    layui.use('form', function(){
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        var descs = $("#descriptiondesc").val();
        console.log("descs is " +descs);
        form.val('example',{"content":descs});
    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#statetime'
            ,type: 'datetime'
            ,eventElem: '#statetime'
            ,trigger: 'click'
        });
        laydate.render({
            elem: '#endtime'
            ,type: 'datetime'
            ,eventElem: '#endtime'
            ,trigger: 'click'
        });
    });
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#file' //绑定元素
            ,url: '/ajaxData/uploadFile' //上传接口
            ,done: function(res){
                //上传完毕回调
                $("#posterPicture").attr("src", res.srcPath);
                $("#posterPictureValue").val(res.showPath);

            }
            ,error: function(){
                //请求异常回调
                console.log("请求异常回调");
            }
        });
    });

    function Issubmit(){
        var date =null;
        var aucid =$("#aucid").val();
        if(aucid==null||aucid==""){
            data = {
                auctionname:$("#auctionname").val(),
                statetime:$("#statetime").val(),
                endtime:$("#endtime").val(),
                // artcodes:$("#artcodes").val(),
                address:$("#address").val(),
                type:$("#type").val(),
                posterPicture:$("#posterPictureValue").val(),
                content:$("#content").val(),
                securityprice:$("#securityprice").val()
            };
        }else{
            data = {
                id:aucid,
                auctionname:$("#auctionname").val(),
                statetime:$("#statetime").val(),
                endtime:$("#endtime").val(),
                // artcodes:$("#artcodes").val(),
                address:$("#address").val(),
                type:$("#type").val(),
                posterPicture:$("#posterPictureValue").val(),
                content:$("#content").val(),
                securityprice:$("#securityprice").val()
            };
        }

        $.ajax({
            url:"/tBizAuction/saveOrUpdate",
            type:'post',
            dataType:'text',
            contentType: 'application/json',
            data:JSON.stringify(data),
            timeout:2000,
            success:function(data){
                var layer = parent.layui.layer;
                if(data.oper_res)
                    layer.msg('操作成功!',{icon:1,time:1000});
                else
                    layer.msg('操作失败!',{icon:1,time:1000});
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },
            error:function () {
                var layer = parent.layui.layer;
                layer.msg("操作失败",{icon:1,time:1000});
            }
        })
    }

</script>

</body>

</html>
